//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for Glacier
public struct GlacierErrorType: AWSErrorType {
    enum Code: String {
        case insufficientCapacityException = "InsufficientCapacityException"
        case invalidParameterValueException = "InvalidParameterValueException"
        case limitExceededException = "LimitExceededException"
        case missingParameterValueException = "MissingParameterValueException"
        case policyEnforcedException = "PolicyEnforcedException"
        case requestTimeoutException = "RequestTimeoutException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serviceUnavailableException = "ServiceUnavailableException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize Glacier
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// Returned if there is insufficient capacity to process this expedited request. This error only applies to expedited retrievals and not to standard or bulk retrievals.
    public static var insufficientCapacityException: Self { .init(.insufficientCapacityException) }
    /// Returned if a parameter of the request is incorrectly specified.
    public static var invalidParameterValueException: Self { .init(.invalidParameterValueException) }
    /// Returned if the request results in a vault or account limit being exceeded.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// Returned if a required header or parameter is missing from the request.
    public static var missingParameterValueException: Self { .init(.missingParameterValueException) }
    /// Returned if a retrieval job would exceed the current data policy's retrieval rate limit. For more information about data retrieval policies,
    public static var policyEnforcedException: Self { .init(.policyEnforcedException) }
    /// Returned if, when uploading an archive, Amazon S3 Glacier times out while receiving the upload.
    public static var requestTimeoutException: Self { .init(.requestTimeoutException) }
    /// Returned if the specified resource (such as a vault, upload ID, or job ID) doesn't exist.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// Returned if the service cannot complete the request.
    public static var serviceUnavailableException: Self { .init(.serviceUnavailableException) }
}

extension GlacierErrorType: Equatable {
    public static func == (lhs: GlacierErrorType, rhs: GlacierErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension GlacierErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
